package bin_tree.heap;

import Stack_Queue.queue.Queue;

/**
 * 基于最大堆的优先级队列
 * 优先级：值越大优先级越高
 */
public class PriorityQueue implements Queue<Integer> {
    private MaxHeap heap;

    public PriorityQueue() {
        heap = new MaxHeap();
    }

    @Override
    public void offer(Integer val) {
        heap.add(val);
    }

    @Override
    public Integer poll() {
        return heap.extractMax();
    }

    @Override
    public Integer peek() {
        return heap.peekMax();
    }

    @Override
    public boolean isEmpty() {
        return heap.isEmpty();
    }
}
